package edu.ut.ece382c.valloy.hierarchy;

import java.util.ArrayList;
import java.util.List;


public class Node<T> {
 
    public T data;
    public List<Node<T>> children;
    public Node<T> parent;
  
    public Node(T data, Node<T> parent) {
        super();
        setData(data);
        this.parent = parent;
    }
     
    public List<Node<T>> getChildren() {
        if (this.children == null) 
            return new ArrayList<Node<T>>();
        return this.children;
    }
   
    public int getNumberOfChildren() {
        if (children == null) 
            return 0;
        return children.size();
    }
     
    public void addChild(Node<T> child) {
        if (children == null) 
            children = new ArrayList<Node<T>>();
        children.add(child);
    }
     
    public T getData() {
        return this.data;
    }
 
    public void setData(T data) {
        this.data = data;
    }
}
